/*
 * imx8-capture.c
 *
 *  Created on: 2024年3月12日
 *      Author: NI
 */

#include "imx8-capture.h"
#include "dlfcn.h"
#include <stdio.h>
//typedef struct _capture_device {
//	capture_context_t *ctx;
//	char lib_path[64];
//
//} capture_device_t;
void *handle;

int capture_get_device_api1(const char *lib_name, int dev_type, capture_api_t *api)
{
	handle = dlopen(lib_name, RTLD_LOCAL);
	if(!handle) {
		printf("dlopen %s error: %s\n", lib_name, dlerror());
		goto error_lib;
	}

	api->capture_create_buffers = dlsym(handle, "capture_create_buffers");
	api->capture_create_context = dlsym(handle, "capture_create_context");
	api->capture_destroy_context = dlsym(handle, "capture_destroy_context");
	api->capture_get_frame = dlsym(handle, "capture_get_frame");
	api->capture_get_property_i = dlsym(handle, "capture_get_property_i");
	api->capture_get_property_p = dlsym(handle, "capture_get_property_p");
	api->capture_is_property = dlsym(handle, "capture_is_property");
	api->capture_release_frame = dlsym(handle, "capture_release_frame");
	api->capture_set_property_i = dlsym(handle, "capture_set_property_i");
	api->capture_set_property_p = dlsym(handle, "capture_set_property_p");
	api->capture_update = dlsym(handle, "capture_update");
	api->capture_get_reg = dlsym(handle, "capture_get_reg");

//	if (api_check(dev_type, api) != 0) {
//		printf("api type %d check error\n", dev_type);
//		goto error_api;
//	}

	return 0;

//error_api:
//	dlclose(handle);

error_lib:
	return -1;
}

//int soc_capture_init(char * path){
//	capture_get_device_api(path, 0, &api);
//
//	return 0;
//}
